﻿Imports ccapps.Web.page
Imports System.Data.OracleClient

Namespace persistent
    Public Class PriceGroupChange
        Private Shared ConnStr As String = GlobalVar.OraConnStr

        Private Shared dbPackageName As String = "eu_bill.PriceGroupChange."

        Public Shared Function getcustomerInfoFromCustcode(ByVal pin_custcode As String) As DataTable

            Dim command As New OracleCommand(dbPackageName & "GetCustInfoFromCustcode")
            command.Parameters.Add("pin_custcode", OracleType.VarChar).Value = pin_custcode
            command.Parameters.Add("p_cursor", OracleType.Cursor).Direction = ParameterDirection.Output
            'LOGLAMA
            Dim Query As String = "Select * from dual "
            Dim gen As Object = New GPOPrepaidToAveaPostpaidCustomerCreate()
            persistent.myDBConn.ORAScalar_LOG(Query, pin_custcode, "null", "null", "null", "Select(btnCheckCustCode_Clic)", "PriceGroupChange", gen.Session("user"))
            Return ExecuteDataTable(command)


        End Function
        Public Shared Function getcustomerInfoFromMSISDN(ByVal pin_MSISDN As String) As DataTable

            Dim command As New OracleCommand(dbPackageName & "GetCustInfoFromMSISDN")
            command.Parameters.Add("pin_MSISDN", OracleType.VarChar).Value = pin_MSISDN
            command.Parameters.Add("p_cursor", OracleType.Cursor).Direction = ParameterDirection.Output
            'LOGLAMA
            Dim Query As String = "Select * from dual "
            Dim gen As Object = New GPOPrepaidToAveaPostpaidCustomerCreate()
            persistent.myDBConn.ORAScalar_LOG(Query, "null", "null", "null", pin_MSISDN, "Select(btnCheckMsisdn_Click)", "PriceGroupChange", gen.Session("user"))
            Return ExecuteDataTable(command)


        End Function

        'procedure PrgCodeAndRpCodeChange (pin_prg_code in integer,pin_cs_id IN integer,pin_rp_code in integer, p_cursor OUT r_cursor_type)

        'procedure PrgCodeAndRpCodeChange (pin_prg_code in integer,pin_custcode IN varchar2,pin_rp_code in integer, p_cursor OUT r_cursor_type)
        'procedure PrgCodeAndRpCodeChange_2(pin_prg_code in varchar2,pin_custcode IN varchar2,pin_rp_code in integer, p_cursor OUT r_cursor_type)
        Public Shared Function PrgCodeAndRpCodeChange(pin_prg_code As Integer, pin_custcode As String, pin_rp_code As Integer) As DataTable

            Dim command As New OracleCommand(dbPackageName & "PrgCodeAndRpCodeChange_2")
            command.Parameters.Add("pin_prg_code", OracleType.VarChar).Value = pin_prg_code
            command.Parameters.Add("pin_custcode", OracleType.VarChar).Value = pin_custcode
            command.Parameters.Add("pin_rp_code", OracleType.Int32).Value = pin_rp_code
            command.Parameters.Add("p_cursor", OracleType.Cursor).Direction = ParameterDirection.Output
            'LOGLAMA
            Dim Query As String = "Select * from dual "
            Dim gen As Object = New GPOPrepaidToAveaPostpaidCustomerCreate()
            persistent.myDBConn.ORAScalar_LOG(Query, pin_custcode, "", "null", "null", "Select(ChangePriceGroup)", "PriceGroupChange", gen.Session("user"))
            Return ExecuteDataTable(command)


        End Function
        'PROCEDURE changeprgcodewithprocess (pin_custcode IN varchar2,  p_cursor OUT r_cursor_type);
        Public Shared Function changeprgcodewithprocess(pin_custcode As String) As DataTable

            Dim command As New OracleCommand(dbPackageName & "changeprgcodewithprocess")
            command.Parameters.Add("pin_custcode", OracleType.VarChar).Value = pin_custcode
            command.Parameters.Add("p_cursor", OracleType.Cursor).Direction = ParameterDirection.Output
            'LOGLAMA
            Dim Query As String = "Select * from dual "
            Dim gen As Object = New GPOPrepaidToAveaPostpaidCustomerCreate()
            persistent.myDBConn.ORAScalar_LOG(Query, pin_custcode, "", "null", "null", "Select(ChangePriceGroup)", "PriceGroupChange", gen.Session("user"))
            Return ExecuteDataTable(command)


        End Function
        '  PROCEDURE yetkicontrol (role_id IN integer, p_cursor OUT r_cursor_type)
        Public Shared Function yetkicontrol(role_id As String) As DataTable

            Dim command As New OracleCommand(dbPackageName & "yetkicontrol")
            command.Parameters.Add("v_role_id", OracleType.VarChar).Value = role_id
            command.Parameters.Add("p_cursor", OracleType.Cursor).Direction = ParameterDirection.Output
            'LOGLAMA
            Return ExecuteDataTable(command)


        End Function
        'PROCEDURE changeprgcodewithprocess2 (pin_custcode IN varchar2,v_dest_tmcode in integer,pin_sure_kisit in varchar2, p_cursor OUT r_cursor_type)
        Public Shared Function changeprgcodewithprocess2(pin_custcode As String, v_dest_tmcode As Integer, pin_sure_kisit As String, v_processid As Integer) As DataTable

            Dim command As New OracleCommand(dbPackageName & "changeprgcodewithprocess2")
            command.Parameters.Add("pin_custcode", OracleType.VarChar).Value = pin_custcode
            command.Parameters.Add("v_dest_tmcode", OracleType.VarChar).Value = v_dest_tmcode
            command.Parameters.Add("pin_sure_kisit", OracleType.VarChar).Value = pin_sure_kisit
            command.Parameters.Add("v_processid", OracleType.Int32).Value = v_processid
            command.Parameters.Add("p_cursor", OracleType.Cursor).Direction = ParameterDirection.Output
            'LOGLAMA
            Dim Query As String = "Select * from dual "
            Dim gen As Object = New GPOPrepaidToAveaPostpaidCustomerCreate()
            persistent.myDBConn.ORAScalar_LOG(Query, pin_custcode, "", "null", "null", "Select(ChangePriceGroup)", "PriceGroupChange", gen.Session("user"))
            Return ExecuteDataTable(command)


        End Function
        '  PROCEDURE changeprgcodewithprocess3 (pin_prgcode in integer,pin_custcode IN varchar2, p_cursor OUT r_cursor_type)
        Public Shared Function changeprgcodewithprocess3(pin_prgcode As Integer, pin_custcode As String) As DataTable

            Dim command As New OracleCommand(dbPackageName & "changeprgcodewithprocess3")
            command.Parameters.Add("pin_prgcode", OracleType.Int32).Value = pin_prgcode
            command.Parameters.Add("pin_custcode", OracleType.VarChar).Value = pin_custcode
            command.Parameters.Add("p_cursor", OracleType.Cursor).Direction = ParameterDirection.Output
            'LOGLAMA
            Dim Query As String = "Select * from dual "
            Dim gen As Object = New GPOPrepaidToAveaPostpaidCustomerCreate()
            persistent.myDBConn.ORAScalar_LOG(Query, pin_custcode, "", "null", "null", "Select(ChangePriceGroup)", "PriceGroupChange", gen.Session("user"))
            Return ExecuteDataTable(command)


        End Function
        '  PROCEDURE createprocess (p_cursor OUT r_cursor_type)
        Public Shared Function createprocess() As DataTable

            Dim command As New OracleCommand(dbPackageName & "createprocess")
            command.Parameters.Add("p_cursor", OracleType.Cursor).Direction = ParameterDirection.Output

            Return ExecuteDataTable(command)


        End Function
        'PROCEDURE getprgcode(pin_custcode in varchar2,p_cursor OUT r_cursor_type)
        Public Shared Function getprgcode(pin_custcode As String) As DataTable

            Dim command As New OracleCommand(dbPackageName & "getprgcode")
            'command.Parameters.Add("pin_prg_code", OracleType.Int32).Value = pin_prg_code
            command.Parameters.Add("pin_custcode", OracleType.VarChar).Value = pin_custcode
            'command.Parameters.Add("pin_rp_code", OracleType.Int32).Value = pin_rp_code
            command.Parameters.Add("p_cursor", OracleType.Cursor).Direction = ParameterDirection.Output
            'LOGLAMA
            Dim Query As String = "Select * from dual "
            Dim gen As Object = New GPOPrepaidToAveaPostpaidCustomerCreate()
            persistent.myDBConn.ORAScalar_LOG(Query, pin_custcode, "", "null", "null", "Select(ChangePriceGroup)", "PriceGroupChange", gen.Session("user"))
            Return ExecuteDataTable(command)


        End Function
        'procedure PrgGroupChange (pin_prg_code in integer,pin_cs_id IN integer, p_cursor OUT r_cursor_type)
        'PROCEDURE changeprgcode (pin_prg_code in number,pin_custcode IN varchar2, p_cursor OUT r_cursor_type)
        'procedure changePrgGroupChange (pin_prg_code in varchar2,pin_custcode IN varchar2, p_cursor OUT r_cursor_type)
        Public Shared Function PrgGroupChange(pin_prg_code As String, pin_custcode As String) As DataTable
            Dim command As New OracleCommand(dbPackageName & "changePrgGroupChange")
            command.Parameters.Add("pin_prg_code", OracleType.VarChar).Value = pin_prg_code
            command.Parameters.Add("pin_custcode", OracleType.VarChar).Value = pin_custcode
            command.Parameters.Add("p_cursor", OracleType.Cursor).Direction = ParameterDirection.Output
            'LOGLAMA
            Dim Query As String = "Select * from dual "
            Dim gen As Object = New GPOPrepaidToAveaPostpaidCustomerCreate()
            persistent.myDBConn.ORAScalar_LOG(Query, pin_custcode, "", "null", "null", "Select(ChangePriceGroup)", "PriceGroupChange", gen.Session("user"))
            Return ExecuteDataTable(command)


        End Function

        Public Shared Function getcustomertype(ByVal pin_tmcode As String, ByVal pin_prgcode As String) As DataTable

            Dim command As New OracleCommand(dbPackageName & "getcustomertype")
            command.Parameters.Add("pin_tmcode", OracleType.VarChar).Value = pin_tmcode
            command.Parameters.Add("pin_prgcode", OracleType.VarChar).Value = pin_prgcode
            command.Parameters.Add("p_cursor", OracleType.Cursor).Direction = ParameterDirection.Output
            Return ExecuteDataTable(command)

        End Function
        Public Shared Function TarifeGetir() As DataTable

            Dim command As New OracleCommand(dbPackageName & "tarifegetir")
            command.Parameters.Add("p_cursor", OracleType.Cursor).Direction = ParameterDirection.Output
            Return ExecuteDataTable(command)

        End Function

        Public Shared Function ExecuteNonQuery(ByVal command As OracleCommand, ByRef MESSAGE As String)
            Dim connection As New OracleConnection(ConnStr)
            command.Connection = connection
            command.CommandType = CommandType.StoredProcedure

            Try
                connection.Open()
                command.ExecuteNonQuery()
            Catch ex As Exception
                MESSAGE = ex.Message.ToString
            Finally
                connection.Close()
            End Try
        End Function
        Public Shared Function ExecuteDataTable(ByVal command As OracleCommand, Optional ByVal directSql As Boolean = 0) As DataTable
            Dim connection As New OracleConnection(ConnStr)
            Dim dataAdapter As New OracleDataAdapter(command)
            Dim dataTable As New DataTable
            Dim dataSet As New DataSet

            command.Connection = connection

            If Not (directSql) Then
                command.CommandType = CommandType.StoredProcedure
            End If

            Try
                connection.Open()
                dataAdapter.Fill(dataSet)
                dataTable = dataSet.Tables(0)
            Catch ex As Exception
            Finally
                connection.Close()
                dataSet.Dispose()
            End Try

            Return dataTable
        End Function
    End Class
End Namespace